package com.zzj.portalwebsite.utlis;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;

/**
 * shopping
 * com.java2405.shopping.utils
 * 类功能描述
 *
 * @author: 尘心
 * @date: 2025/2/20 上午 10:36
 */
public class StrConvertLocalDateTime {
    public static LocalDateTime strToLocalDateTime(String dateTimeStr){
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime dateTime = null;
        try {
            dateTime = LocalDateTime.parse(dateTimeStr, formatter);
            System.out.println("转换后的 LocalDateTime: " + dateTime);
            return dateTime;
        } catch (DateTimeParseException e) {
            System.err.println("日期时间字符串格式不正确: " + e.getMessage());
        }
        return null;
    }
}
